import { request } from 'umi';

import GoodsType from '@/pages/goods/type';
/**
 *
 * @returns
 * GET 请求代表获取数据
 * POST 请求代表新增数据
 * PUT 请求代表更新数据
 * DELETE 请求代表删除数据
 */
const api = {
  getStu: () => {
    return request('/stu', {
      method: 'GET',
    });
  },
  deleteStu: (data) => {
    return request(`/stu/${data.objectId}`, {
      method: 'DELETE',
    });
  },
  addCateCake: (data: string) => {
    return request('/cakeCate', {
      method: 'POST',
      data,
    });
  },
  getCateCake: () => {
    return request('/cakeCate', {
      method: 'GET',
    });
  },
  updateCateCake: (data) => {
    return request(`/cakeCate/${data.objectId}`, {
      method: 'PUT',
      data,
    });
  },
  deleteCateCake: (data) => {
    return request(`/cakeCate/${data.objectId}`, {
      method: 'DELETE'
    });
  },
  getBanner: () => {
    return request('/banner',{
      method: 'GET'
    })
  },
  addBanner: (data) => {
    return request('/banner', {
      method: 'POST',
      data,
    });
  },
  deleteBanner: (data) => {
    return request(`/banner/${data.objectId}`, {
      method: 'DELETE'
    })
  },
  getBannerByObjectId: (objectId) => {
    return request(`/banner/${objectId}`, {
      method: 'GET'
    })
  },
  updateBanner: (data) => {
    return request(`/banner/${data.objectId}`, {
      method: 'PUT',
      data
    })
  },
  addGoods: (data: GoodsType) => {
    return request('/goods', {
      method: 'POST',
      data
    })
  },
  getGoods: () => {
    return request('/goods', {
      method: 'GET'
    })
  }
};
export default api;
